﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using PalFramework.Manager;
using PalBattleEmulator.Graphic;
using PalBattleEmulator.Battle;
using PalBattleEmulator.Manager;
using PalBattleEmulator.Manager.Tempate;
using PalBattleEmulator.Manager.Resource;

namespace PalBattleEmulator
{
    public static class ContextModules
    {
        public static Dispatcher MainDispatcher;          
        public static GameClockManager GameClockManager;
        public static GameGraphicManager GraphicControl;
        public static GameBattleManager BattleManager;

        //template managers
        public static CharacterTmplManager CharacterTmplManager;
        public static EnemyTmplManager EnemyTmplManager;
        public static CharacterArrayTmplManager CharacterArrayTmplManager;
        public static EnemyArrayTmplManager EnemyArrayTmplManager;
        public static MagicEffectTmplManager MagicEffectTmplManager;

        //resource managers
        public static SingleFrameImageManager BattleFieldImageManager;
        public static MultiFrameImageManager CharacterImageManager;
        public static MultiFrameImageManager EnemyImageManager;
        public static MultiFrameImageManager EffectImageManager;
        

        public static void InitializeModules()
        {
            //battle
            BattleManager = new GameBattleManager();

            //template
            CharacterTmplManager = new CharacterTmplManager();
            CharacterTmplManager.Initialize();

            EnemyTmplManager = new EnemyTmplManager();
            EnemyTmplManager.Initialize();

            CharacterArrayTmplManager = new CharacterArrayTmplManager();
            CharacterArrayTmplManager.Initialize();

            EnemyArrayTmplManager = new EnemyArrayTmplManager();
            EnemyArrayTmplManager.Initialize();

            MagicEffectTmplManager = new MagicEffectTmplManager();
            MagicEffectTmplManager.Initialize();

            //resource
            BattleFieldImageManager = new SingleFrameImageManager(GlobalConfig.DIR_NAME_RESOURCE_BATTLE_FIELD, GlobalConfig.FILE_FORMAT_PICTURE_BATTLE_FIELD, false);
            BattleFieldImageManager.Initialize();

            CharacterImageManager = new MultiFrameImageManager(GlobalConfig.DIR_NAME_RESOURCE_CHARACTER, GlobalConfig.FILE_FORMAT_PICTURE_CHARACTER, false);
            CharacterImageManager.Initialize();

            EnemyImageManager = new MultiFrameImageManager(GlobalConfig.DIR_NAME_RESOURCE_ENEMY, GlobalConfig.FILE_FORMAT_PICTURE_ENEMY, false);
            EnemyImageManager.Initialize();

            EffectImageManager = new MultiFrameImageManager(GlobalConfig.DIR_NAME_RESOURCE_MAGIC, GlobalConfig.FILE_FORMAT_PICTURE_MAGIC, false);
            EffectImageManager.Initialize();

            //最后初始化主时钟
            GameClockManager = new GameClockManager();
            GameClockManager.Initialize();

        }
    }
}
